import MySQLdb

class Relatorio:
    
    def __init__(self):
        self.idEquipamento = ""
        self.status = ""

    def getIdEquipamento(self):
        return self.idEquipamento

    def getStatus (self):
        return self.status



    
    def RelatorioCompleto(self):
        db = MySQLdb.connect("localhost","root","","gtec" )
        cursor = db.cursor()        
        cursor.execute("SELECT * FROM equipamento")
        pesq = cursor.fetchall()
        print "Status: TODOS \n|ID |"
        for coluna in pesq:  print  "|",coluna[0],"|" , "\n Descricao: ",coluna[1], "\n Marca: ",coluna[2] , "\n Modelo: ",coluna[3] , "\n Acessorio: ",coluna[4] , "\n HD ", \
            coluna[5] , "\n Memoria: ",coluna[6] , "\n Processador: ",coluna[7] , "\n | Status: ",coluna[8]," |\n\n"
        db.commit()



        
        
    def RelatorioStatus(self,Status):
        
        db = MySQLdb.connect("localhost","root","","gtec" )
        cursor = db.cursor()
        comando = """ SELECT * FROM equipamento WHERE status = "%s" """%(Status)
        cursor.execute(comando)
        pesq = cursor.fetchall()
        print "Status: ",Status, "\n|ID |"
        for coluna in pesq: print  "|",coluna[0],"|" , "\n Descricao: ",coluna[1], "\n Marca: ",coluna[2] , "\n Modelo: ",coluna[3] , "\n Acessorio: ",coluna[4] , "\n HD ", \
            coluna[5] , "\n Memoria: ",coluna[6] , "\n Processador: ",coluna[7] , "\n | Status: ",coluna[8]," |\n\n"
        db.commit()

    def RelatorioIdEquipamento(self,getIdEquipamento):
        
        db = MySQLdb.connect("localhost","root","","gtec" )
        cursor = db.cursor()
        comando = """ SELECT * FROM equipamento WHERE IdEquipamento = "%s" """%(getIdEquipamento)
        cursor.execute(comando)
        pesq = cursor.fetchall()
        for coluna in pesq: print "|",coluna[0],"|" , "\n Descricao: ",coluna[1], "\n Marca: ",coluna[2] , "\n Modelo: ",coluna[3] , "\n Acessorio: ",coluna[4] , "\n HD ", \
            coluna[5] , "\n Memoria: ",coluna[6] , "\n Processador: ",coluna[7] , "\n | Status: ",coluna[8]," |\n\n"
        db.commit()

        
        """DIAGNOSTICOS"""
    def diagEquipamento(self,getIdEquipamento):
        db = MySQLdb.connect("localhost","root","","gtec" )
        cursor = db.cursor()
        comando = """ SELECT * FROM diagnostico WHERE IdEquipamento = "%s" """%(getIdEquipamento)
        cursor.execute(comando)
        pesq = cursor.fetchall()
        for coluna in pesq: print "Diagnostico: ", coluna[1] ,"\n Tecnico Responsavel: ", coluna[2],"\n"
        db.commit()
